<template>
    <div class="content">
      <!--结果-->
        <div class="result">
          <span class="large">{{fen}}</span>分
          <p>答题时间：{{examTime}} / 错题数：{{cuo}}</p>
          <div class="again" @click="toIndex()">
            再考一次
          </div>
        </div>
   <!---->
      <div  class="content">
        <!--导航条-->
        <div class="tag">
          <div class="tag_zhong">
            <div @click="style(1)" v-bind:class="style1">
              错题
            </div>
            <div @click="style(2)" v-bind:class="style2">
              标记题
            </div>
          </div>
        </div>
        <!--全部题-->
        <div v-if="show==1" class="answer_three">
          <div class="answer_three_header">
            共 {{radio.length+check.length+judge.length+fill.length}} 道题 <span>(其中单选题{{radio.length}}道，多选题{{check.length}}道，判断题{{judge.length}}道，填空题{{fill.length}}道)</span>
          </div>

          <!--单选题-->
          <div class="topic_ceshi">
            <div class="answer_three_tips">
              <span class="zi_lan">单选题</span>
            </div>
            <div v-for="(radios, index) in radio" class="tkj">
              <div class="subject">
                {{index+1}}. {{radios.content}}
              </div>
              <ul>
                <li v-for="radioss in radios.option">
                  {{radioss}}
                </li>
                <li>
                  正确答案：<span style="color: #3B50A1">{{radios.correctAnswer}}</span>          </li>
              </ul>

            </div>
          </div>
          <!--多选题-->
          <div class="topic_ceshi">
            <div class="answer_three_tips">
              <span class="zi_lan">多选题</span>
            </div>
            <div v-for="(checks, index) in check" class="tkj">
              <div class="subject">
                {{radio.length+(index+1) }}. {{checks.content}}
              </div>
              <ul>
                <li v-for="checkss in checks.option">
                  {{checkss}}
                </li>
                <li>
                  正确答案：<span style="color: #3B50A1">{{checks.correctAnswer}}</span>          </li>
              </ul>

            </div>
          </div>
          <!--判断题-->
          <div class="topic_ceshi">
            <div class="answer_three_tips">
              <span class="zi_lan">判断题</span>
            </div>
            <div v-for="(judges, index) in judge" class="tkj">
              <div class="subject">
                {{(check.length+radio.length)+(index+1) }}. {{judges.content}}
              </div>
              <ul>
                <li v-for="judgess in judges.option">
                  {{judgess}}
                </li>
                <li>正确答案：<span style="color: #3B50A1">{{judges.correctAnswer}}</span>          </li>
              </ul>

            </div>
          </div>
          <!--填空题-->
          <div class="topic_ceshi">
            <div class="answer_three_tips">
              <span class="zi_lan">填空题</span>
            </div>
            <div v-for="(judgess, index) in fill" class="tkj">
              <div class="subject">
                {{(check.length+radio.length+judge.length)+(index+1) }}. {{judgess.content}}
              </div>
              <ul>
                <li>正确答案：<span style="color: #3B50A1">{{judgess.correctAnswer}}</span>          </li>
              </ul>

            </div>
          </div>


        </div>
        <!--标记题-->
        <div v-if="show==2" class="answer_three">
          <div class="answer_three_header">
            共 {{markRadio.length+checkRadio.length+judgeRadio.length+fillRadio.length}} 道题 <span>(其中单选题{{markRadio.length}}道，多选题{{checkRadio.length}}道，判断题{{judgeRadio.length}}道，填空题{{fillRadio.length}}道)</span>
          </div>

          <!--单选题-->
          <div class="topic_ceshi">
            <div class="answer_three_tips">
              <span class="zi_lan">单选题</span>
            </div>
            <div v-for="(radios, index) in markRadio" class="tkj">
              <div class="subject">
                {{index+1}}. {{radios.content}}
              </div>
              <ul>
                <li v-for="radioss in radios.option">
                  {{radioss}}
                </li>
                <li>正确答案：<span style="color: #3B50A1">{{radios.correctAnswer}}</span>          </li>
              </ul>

            </div>
          </div>
          <!--多选题-->
          <div class="topic_ceshi">
            <div class="answer_three_tips">
              <span class="zi_lan">多选题</span>
            </div>
            <div v-for="(checks, index) in checkRadio" class="tkj">
              <div class="subject">
                {{radio.length+(index+1) }}. {{checks.content}}
              </div>
              <ul>
                <li v-for="checkss in checks.option">
                  {{checkss}}
                </li>
                <li>正确答案：<span style="color: #3B50A1">{{checks.correctAnswer}}</span>          </li>
              </ul>

            </div>
          </div>
          <!--判断题-->
          <div class="topic_ceshi">
            <div class="answer_three_tips">
              <span class="zi_lan">判断题</span>
            </div>
            <div v-for="(judges, index) in judgeRadio" class="tkj">
              <div class="subject">
                {{(check.length+radio.length)+(index+1) }}. {{judges.content}}
              </div>
              <ul>
                <li v-for="judgess in judges.option">
                  {{judgess}}
                </li>
                <li>正确答案：<span style="color: #3B50A1">{{judges.correctAnswer}}</span>          </li>
              </ul>

            </div>
          </div>
          <!--填空-->
          <div class="topic_ceshi">
            <div class="answer_three_tips">
              <span class="zi_lan">填空题</span>
            </div>
            <div v-for="(judgess, index) in fillRadio" class="tkj">
              <div class="subject">
                {{(check.length+radio.length+judge.length)+(index+1) }}. {{judgess.content}}
              </div>
              <ul>
                <li>正确答案：<span style="color: #3B50A1">{{judgess.correctAnswer}}</span>          </li>
              </ul>

            </div>
          </div>


        </div>
      </div>
    </div>
</template>

<script>
    export default {
        name: '',
        data() {
            return {


              style1:'click',
              style2:'',


              radio:[],//单选题
              check:[],//多选题
              judge:[],//判断题
              fill:[],//填空题

              markRadio:[], //标记单选题
              checkRadio:[], //标记多选题
              judgeRadio:[], //标记判断题
              fillRadio:[], //标记填空题
              show:1,
              fen:'',
              examTime:'',//时间
              cuo:''
            }
        },
      methods: {

        style(e){//调节标题样式
          if(e==1){
            this.show=1;
            this.style1='click';
            this.style2='';
          }
          if(e==2){
            this.show=2;
            this.style1='';
            this.style2='click';
          }

        },
        toIndex(){
          this.$router.push({  //核心语句
            path:'/index',   //跳转的路径
            query:{           //路由传参时push和query搭配使用 ，作用时传递参数
            }
          })
        },
          ajjax(){
            var examDetailId= this.$route.query.examDetailId//结果id
            console.log(examDetailId)
            this.$axios({
              url: 'web/subject/exam/grade/'+examDetailId,
              method: 'GET',
              data:{
              },
              headers: {
                'Content-Type': 'application/json;charset=UTF-8'
              },
              transformRequest: [function(data) {  //json
                data = JSON.stringify(data);
                return data
              }],
            }).then((response) => {
              console.log(response.data);
              if(response.data.code==500){
                this.$Message.error('获取失败！');
              }else {
                this.fen = response.data.grade;
                this.examTime = parseInt(response.data.examTime / 60) + '分' + parseInt(response.data.examTime % 60) + '秒';
                this.cuo = response.data.wrongOfNumbers;

                for (var j = 0; j < response.data.markQuestions.length; j++) {
                  if (response.data.markQuestions[j].type == 1) {
                    var strArr = [];
                    if (response.data.markQuestions[j].optionA == '' || response.data.markQuestions[j].optionA == null) {
                    } else {
                      strArr.push("A  " + response.data.markQuestions[j].optionA)
                    }
                    if (response.data.markQuestions[j].optionB == '' || response.data.markQuestions[j].optionB == null) {
                    } else {
                      strArr.push("B  " + response.data.markQuestions[j].optionB)
                    }
                    if (response.data.markQuestions[j].optionC == '' || response.data.markQuestions[j].optionC == null) {
                    } else {
                      strArr.push("C  " + response.data.markQuestions[j].optionC)
                    }
                    if (response.data.markQuestions[j].optionD == '' || response.data.markQuestions[j].optionD == null) {
                    } else {
                      strArr.push("D  " + response.data.markQuestions[j].optionD)
                    }
                    if (response.data.markQuestions[j].optionE == '' || response.data.markQuestions[j].optionE == null) {
                    } else {
                      strArr.push("E  " + response.data.markQuestions[j].optionE)
                    }

                    this.markRadio.push({
                      content: response.data.markQuestions[j].content,//题名
                      correctAnswer: response.data.markQuestions[j].correctAnswer,//正确答案
                      id: response.data.markQuestions[j].id,//题目id
                      option: strArr,//题选项
                      questionType: response.data.markQuestions[j].type,//题型
                      userAnswer: response.data.markQuestions[j].userAnswers,//用户答案
                    })
                    console.log(this.markRadio)
                  }
//              渲染标记多选题
                  if (response.data.markQuestions[j].type == 2) {
                    var strArr = [];
                    if (response.data.markQuestions[j].optionA == '' || response.data.markQuestions[j].optionA == null) {
                    } else {
                      strArr.push("A  " + response.data.markQuestions[j].optionA)
                    }
                    if (response.data.markQuestions[j].optionB == '' || response.data.markQuestions[j].optionB == null) {
                    } else {
                      strArr.push("B  " + response.data.markQuestions[j].optionB)
                    }
                    if (response.data.markQuestions[j].optionC == '' || response.data.markQuestions[j].optionC == null) {
                    } else {
                      strArr.push("C  " + response.data.markQuestions[j].optionC)
                    }
                    if (response.data.markQuestions[j].optionD == '' || response.data.markQuestions[j].optionD == null) {
                    } else {
                      strArr.push("D  " + response.data.markQuestions[j].optionD)
                    }
                    if (response.data.markQuestions[j].optionE == '' || response.data.markQuestions[j].optionE == null) {
                    } else {
                      strArr.push("E  " + response.data.markQuestions[j].optionE)
                    }

                    this.checkRadio.push({
                      content: response.data.markQuestions[j].content,//题名
                      correctAnswer: response.data.markQuestions[j].correctAnswer,//正确答案
                      id: response.data.markQuestions[j].id,//题目id
                      option: strArr,//题选项
                      questionType: response.data.markQuestions[j].type,//题型
                      userAnswer: response.data.markQuestions[j].userAnswers,//用户答案
                    })
                  }

//              渲染标记判断题
                    if (response.data.markQuestions[j].type == 3) {
                      var strArr = [];
                      if (response.data.markQuestions[j].optionA == '' || response.data.markQuestions[j].optionA == null) {
                      } else {
                        strArr.push("A  " + response.data.markQuestions[j].optionA)
                      }
                      if (response.data.markQuestions[j].optionB == '' || response.data.markQuestions[j].optionB == null) {
                      } else {
                        strArr.push("B  " + response.data.markQuestions[j].optionB)
                      }
                      if (response.data.markQuestions[j].optionC == '' || response.data.markQuestions[j].optionC == null) {
                      } else {
                        strArr.push("C  " + response.data.markQuestions[j].optionC)
                      }
                      if (response.data.markQuestions[j].optionD == '' || response.data.markQuestions[j].optionD == null) {
                      } else {
                        strArr.push("D  " + response.data.markQuestions[j].optionD)
                      }
                      if (response.data.markQuestions[j].optionE == '' || response.data.markQuestions[j].optionE == null) {
                      } else {
                        strArr.push("E  " + response.data.markQuestions[j].optionE)
                      }

                      this.judgeRadio.push({
                        content: response.data.markQuestions[j].content,//题名
                        correctAnswer: response.data.markQuestions[j].correctAnswer,//正确答案
                        id: response.data.markQuestions[j].id,//题目id
                        option: strArr,//题选项
                        questionType: response.data.markQuestions[j].type,//题型
                        userAnswer: response.data.markQuestions[j].userAnswers,//用户答案
                      })}



                  //              填空
                  if (response.data.markQuestions[j].type == 5) {
                    this.fillRadio.push({
                      content: response.data.markQuestions[j].content,//题名
                      correctAnswer: response.data.markQuestions[j].correctAnswer,//正确答案
                      id: response.data.markQuestions[j].id,//题目id
                      questionType: response.data.markQuestions[j].type,//题型
                      userAnswer: response.data.markQuestions[j].userAnswers,//用户答案
                    })
                  }

                }

//----------------------------错题
                for (var i = 0; i < response.data.wrongQuestions.length; i++) {
//              渲染错题单选题
                  if (response.data.wrongQuestions[i].type == 1) {
                    var strArr = [];
                    if (response.data.wrongQuestions[i].optionA == '' || response.data.wrongQuestions[i].optionA == null) {

                    } else {
                      strArr.push("A  " + response.data.wrongQuestions[i].optionA)
                    }
                    if (response.data.wrongQuestions[i].optionB == '' || response.data.wrongQuestions[i].optionB == null) {

                    } else {
                      strArr.push("B  " + response.data.wrongQuestions[i].optionB)
                    }
                    if (response.data.wrongQuestions[i].optionC == '' || response.data.wrongQuestions[i].optionC == null) {


                    } else {
                      strArr.push("C  " + response.data.wrongQuestions[i].optionC)
                    }
                    if (response.data.wrongQuestions[i].optionD == '' || response.data.wrongQuestions[i].optionD == null) {

                    } else {
                      strArr.push("D  " + response.data.wrongQuestions[i].optionD)
                    }
                    if (response.data.wrongQuestions[i].optionE == '' || response.data.wrongQuestions[i].optionE == null) {

                    } else {
                      strArr.push("E  " + response.data.wrongQuestions[i].optionE)
                    }

                    this.radio.push({
                      content: response.data.wrongQuestions[i].content,//题名
                      correctAnswer: response.data.wrongQuestions[i].correctAnswer,//正确答案
                      id: response.data.wrongQuestions[i].id,//题目id
                      option: strArr,//题选项
                      questionType: response.data.wrongQuestions[i].type,//题型
                      userAnswer: response.data.wrongQuestions[i].userAnswers,//用户答案
                    })
                  }
//              渲染错题多选题
                  if (response.data.wrongQuestions[i].type == 2) {
                    var strArr = [];
                    if (response.data.wrongQuestions[i].optionA == '' || response.data.wrongQuestions[i].optionA == null) {

                    } else {
                      strArr.push("A  " + response.data.wrongQuestions[i].optionA)
                    }
                    if (response.data.wrongQuestions[i].optionB == '' || response.data.wrongQuestions[i].optionB == null) {

                    } else {
                      strArr.push("B  " + response.data.wrongQuestions[i].optionB)
                    }
                    if (response.data.wrongQuestions[i].optionC == '' || response.data.wrongQuestions[i].optionC == null) {

                    } else {
                      strArr.push("C  " + response.data.wrongQuestions[i].optionC)
                    }
                    if (response.data.wrongQuestions[i].optionD == '' || response.data.wrongQuestions[i].optionD == null) {

                    } else {
                      strArr.push("D  " + response.data.wrongQuestions[i].optionD)
                    }
                    if (response.data.wrongQuestions[i].optionE == '' || response.data.wrongQuestions[i].optionE == null) {

                    } else {
                      strArr.push("E  " + response.data.wrongQuestions[i].optionE)
                    }

                    this.check.push({
                      content: response.data.wrongQuestions[i].content,//题名
                      correctAnswer: response.data.wrongQuestions[i].correctAnswer,//正确答案
                      id: response.data.wrongQuestions[i].id,//题目id
                      option: strArr,//题选项
                      questionType: response.data.wrongQuestions[i].type,//题型
                      userAnswer: response.data.wrongQuestions[i].userAnswers,//用户答案
                    })
                  }
//              渲染错题判断题
                  if (response.data.wrongQuestions[i].type == 3) {
                    var strArr = [];
                    if (response.data.wrongQuestions[i].optionA == '' || response.data.wrongQuestions[i].optionA == null) {

                    } else {
                      strArr.push("A  " + response.data.wrongQuestions[i].optionA)
                    }
                    if (response.data.wrongQuestions[i].optionB == '' || response.data.wrongQuestions[i].optionB == null) {

                    } else {
                      strArr.push("B  " + response.data.wrongQuestions[i].optionB)
                    }
                    if (response.data.wrongQuestions[i].optionC == '' || response.data.wrongQuestions[i].optionC == null) {

                    } else {
                      strArr.push("C  " + response.data.wrongQuestions[i].optionC)
                    }
                    if (response.data.wrongQuestions[i].optionD == '' || response.data.wrongQuestions[i].optionD == null) {

                    } else {
                      strArr.push("D  " + response.data.wrongQuestions[i].optionD)
                    }
                    if (response.data.wrongQuestions[i].optionE == '' || response.data.wrongQuestions[i].optionE == null) {

                    } else {
                      strArr.push("E  " + response.data.wrongQuestions[i].optionE)
                    }

                    this.judge.push({
                      content: response.data.wrongQuestions[i].content,//题名
                      correctAnswer: response.data.wrongQuestions[i].correctAnswer,//正确答案
                      id: response.data.wrongQuestions[i].id,//题目id
                      option: strArr,//题选项
                      questionType: response.data.wrongQuestions[i].type,//题型
                      userAnswer: response.data.wrongQuestions[i].userAnswers,//用户答案
                    })

                  }
                  if (response.data.wrongQuestions[i].type == 5) {
                    //填空题
                    this.fill.push({
                      content: response.data.wrongQuestions[i].content,//题名
                      correctAnswer: response.data.wrongQuestions[i].correctAnswer,//正确答案
                      id: response.data.wrongQuestions[i].id,//题目id
                      questionType: response.data.wrongQuestions[i].type,//题型
                      userAnswer: response.data.wrongQuestions[i].userAnswers,//用户答案
                    })
                    console.log(this.fill);
                  }
                }
              }
          }).catch((error) => {
              console.log("调取失败500");
              this.$Message.error('提交失败！')
            });
          }
        },
      mounted:function() {
          this.ajjax();
      }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

  .result{
    width: 1080px;
    margin: auto;
    text-align: center;
    font-size: 15px;
    color: #3B50A1;
    padding-top: 51px;
    padding-bottom: 50px;
  }
  .large{
    font-size: 72px;
  }
  .again{
    margin: auto;
    line-height: 40px;
    text-align: center;
    width:150px;
    height:40px;
    background:rgba(255,255,255,1);
    border:1px solid rgba(59,80,161,1);
    border-radius:20px;
    margin-top: 22px;
    cursor: pointer;
  }
.again:hover{
    background: #3B50A1;
  color: white;
}
  .tag{
    width: 100%;
    height:43px;
    background:rgba(255,255,255,1);
    box-shadow:0px 0px 11px 0px rgba(4,0,0,0.1);
  }
  .tag_zhong{
    width: 765px;
    margin: auto;
  }
  .tag_zhong div{
    width:85px;
    height: 100%;
    line-height: 43px;
    text-align: center;
    cursor: pointer;
    display: inline-block;
  }
  .click{
    background: #3B50A1;
    color: white;
  }
  .answer_three{
    width: 765px;
    margin: auto;
    background:rgba(255,255,255,1);
    box-shadow:0px 0px 11px 0px rgba(4,0,0,0.1);
    border-radius:1px;
    padding: 13px;
    margin-top: 18px;
  }
  .answer_three_header{
    width: 100%;
    height: 50px;
    border-bottom: 1px solid #BDBDBD;
    position: relative;
    font-size:13px;
    line-height: 50px;
    color:rgba(51,51,51,1);
  }
  .answer_three_header span{
    color: #999999;
  }
  .zi_lan{
    color: #3B50A1;
  }
  .answer_three_tips{
    color: #999999;
    margin: 14px 0 31px 0;
  }
  .subject{
    line-height: 21px;
    font-size: 12px;
    margin-bottom: 10px;
  }
  .tkj{
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px  dashed  #E7E7E7;
  }
  ul li{
    list-style: none;
    line-height:40px;
    cursor: pointer;
    font-size: 16px;
  }
  .content{
    /*padding-top: 100px;*/
  }
  .tag{
    z-index: 1;
    margin-top: 20px;
    width: 100%;
    height:60px;
    background:rgba(255,255,255,1);
    box-shadow:0px 0px 11px 0px rgba(4,0,0,0.1);
  }
  .tag_zhong{
    width: 1079px;
    margin: auto;
  }
  .tag_zhong div{
    width:120px;
    height: 100%;
    line-height: 60px;
    text-align: center;
    cursor: pointer;
    display: inline-block;
  }

  .answer_three{
    width: 1079px;
    margin: auto;
    background:rgba(255,255,255,1);
    box-shadow:0px 0px 11px 0px rgba(4,0,0,0.1);
    border-radius:1px;
    padding: 18px;
    margin-top: 26px;
  }
  .answer_three_header{
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #BDBDBD;
    position: relative;
    font-size:18px;
    line-height: 70px;
    color:rgba(51,51,51,1);
  }
  .answer_three_header span{
    color: #999999;
  }
  .zi_lan{
    color: #3B50A1;
  }
  .answer_three_tips{
    color: #999999;
    margin: 30px 0 35px 0;
  }
  .subject{
    line-height:30px;
    font-size: 16px;
    margin-bottom: 24px;
  }
  .tkj{
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 2px  dashed  #E7E7E7;
    position: relative;
  }

</style>
